<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Babylon.js</title>
  <!-- Link to the last version of BabylonJS -->
  <!-- <script src="https://preview.babylonjs.com/babylon.js"></script> -->
  <!-- Link to the last version of BabylonJS loaders to enable loading filetypes such as .gltf -->
  <!-- <script src="https://preview.babylonjs.com/loaders/babylonjs.loaders.min.js"></script> -->
  <!-- Link to pep.js to ensure pointer events work consistently in all browsers -->
  <!-- <script src="https://code.jquery.com/pep/0.4.1/pep.js"></script> -->
  <!-- 主程序脚本 -->
  <script src="libs/babylon.js"></script>
  <!-- 扩展对GILF等3D文件的支持(方便你把3D软件中建立的模型导入) -->
  <script src="libs/babylonjs.loaders.min.js"></script>
  <!-- 统一不同浏览器上指针操作 -->
  <script src="libs/pep.js"></script>
  <style>
    html, body {
        overflow: hidden;
        width   : 100%;
        height  : 100%;
        margin  : 0;
        padding : 0;
    }

    #renderCanvas {
        width   : 100%;
        height  : 100%;
        touch-action: none;
    }
  </style>
</head>
<body>
  <canvas id="renderCanvas"></canvas>
  <script>
    window.addEventListener('DOMContentLoaded', function() {
      var canvas = document.getElementById('renderCanvas');
      var engine = new BABYLON.Engine(canvas, true);
      var createScene = function() {
        // Create a basic BJS Scene object.
        var scene = new BABYLON.Scene(engine);

        // Create a FreeCamera, and set its position to (x:0, y:5, z:-10).
        var camera = new BABYLON.FreeCamera('camera', new BABYLON.Vector3(0, 5,-10), scene);

        // Target the camera to scene origin.
        camera.setTarget(BABYLON.Vector3.Zero());

        // Attach the camera to the canvas.
        camera.attachControl(canvas, false);

        // Create a basic light, aiming 0,1,0 - meaning, to the sky.
        var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0,1,0), scene);

        // Create a built-in "sphere" shape. 
        var sphere = BABYLON.MeshBuilder.CreateSphere('sphere', {segments:16, diameter:2}, scene);

        // Move the sphere upward 1/2 of its height.
        sphere.position.y = 1;

        // Create a built-in "ground" shape.
        var ground = BABYLON.MeshBuilder.CreateGround('ground1', {height:6, width:6, subdivisions: 2}, scene);

        // Return the created scene.
        return scene;
      }
      var scene = createScene();
      engine.runRenderLoop(function() {
        scene.render();
      });
      window.addEventListener('resize', function() {
        engine.resize();
      });
    });
  </script>
</body>
</html>